subroutine str2range(str,minn,maxn)

  implicit none

  character :: str*(*)
  integer,intent(out) :: minn,maxn

  integer :: i,foo,boo
  integer :: len_str,asci_code

  minn=-1
  maxn=-1

  str=trim(adjustl(str))
  len_str=len_trim(str)
  if (len_str.eq.0) return

  foo=0
  boo=0

  ! Find "-" character in the string.
  do i=1,len_str
     asci_code=ichar(str(i:i))
     if (asci_code.ne.45.and.&
         asci_code.lt.48.and.&
         asci_code.gt.57) &
         call abnormal_stop("str2range",&
         "Unexpected character appears in the range notation.")
     boo=boo+1
     if (asci_code.eq.45) foo=1
     if (asci_code.eq.45) exit
  end do

  if (foo.eq.0) then
     ! If "-" does not exist in the string,
     ! consider the single number. (minn=maxn)
     read(str(1:len_str),*) minn
     maxn=minn
  else
     ! If "-" exists in the string,
     if (boo.eq.len_str) then
        ! nn-
        read(str(1:boo-1),*) minn
        maxn=-1
     else if (boo.eq.1) then
        ! -nn
        minn=-1
        read(str(boo+1:len_str),*) maxn
     else
        ! nn-nn
        read(str(1:boo-1),*) minn
        read(str(boo+1:len_str),*) maxn
     end if
  end if

  return

end subroutine str2range
